﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CustomerService
{
    public partial class tabRefundsReturns : System.Web.UI.UserControl
    {
        private SalesManagerEntities _context;
        protected tblOrderHeader _orderHeader = _emptyOrder;
        private static tblOrderHeader _emptyOrder = new tblOrderHeader();

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public new void Load(SalesManagerEntities context, tblOrderHeader orderHeader, bool forceUpdate)
        {
            _context = context;
            _orderHeader = orderHeader;
            txtOrderID.Text = _orderHeader.OrderID.ToString();

            if (!IsPostBack || forceUpdate || (Request.Params["__EVENTARGUMENT"] == "UpdateDetails"))
            {
                ListViewReturns.DataSource = from c in _orderHeader.Customer.cachedReturnDetails
                                             where c.RMAReturn.OrderID == _orderHeader.OrderID
                                             select c;
                ListViewReturns.DataBind();

                ListViewRefunds.DataSource = _orderHeader.Customer.cachedRefunds.Where(t=>t.OrderHeader == _orderHeader);
                ListViewRefunds.DataBind();
            }
        }
    }
}